body {
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: #f8f9fa;
    padding: 0;
    margin: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.header {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 10px;
    background-color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    z-index: 100;
    flex-shrink: 0;
}

.back-btn-nav {
    justify-self: start;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #07c160; /* 微信绿 */
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn-nav:hover {
    color: #059d4e; /* 微信绿的深色版本 */
}

.header h1 {
    text-align: center;
    grid-column: 2;
    color: #000000; /* 黑色 */
    font-size: 20px;
    margin: 0;
}

.restart-btn {
    justify-self: end;
    background-color: #07c160;
    color: white;
    border: none;
    padding: 8px 12px;
    font-size: 14px;
    border-radius: 4px;
    cursor: pointer;
}

.restart-btn:hover {
    background-color: #059d4e;
}

.game-wrapper {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 10px;
}

.game-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.game-main {
    display: flex;
    flex: 1;
    gap: 20px;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(10, 30px);
    grid-template-rows: repeat(20, 30px);
    gap: 1px;
    background-color: #ddd;
    border: 2px solid #999;
}

.cell {
    width: 30px;
    height: 30px;
    background-color: white;
    border: 1px solid #eee;
}

.cell.filled {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.cell.I { background-color: #00f0f0; }
.cell.J { background-color: #0000f0; }
.cell.L { background-color: #f0a000; }
.cell.O { background-color: #f0f000; }
.cell.S { background-color: #00f000; }
.cell.T { background-color: #a000f0; }
.cell.Z { background-color: #f00000; }

.game-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 150px;
    flex-shrink: 0;
}

.next-piece {
    background-color: white;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    text-align: center;
}

.next-piece-board {
    display: grid;
    grid-template-columns: repeat(4, 20px);
    grid-template-rows: repeat(4, 20px);
    gap: 1px;
    background-color: #ddd;
    border: 2px solid #999;
    width: fit-content;
    margin: 10px auto;
    padding: 5px;
}

.next-piece-cell {
    width: 20px;
    height: 20px;
    background-color: white;
}

.next-piece-cell.filled {
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.next-piece-cell.I { background-color: #00f0f0; }
.next-piece-cell.J { background-color: #0000f0; }
.next-piece-cell.L { background-color: #f0a000; }
.next-piece-cell.O { background-color: #f0f000; }
.next-piece-cell.S { background-color: #00f000; }
.next-piece-cell.T { background-color: #a000f0; }
.next-piece-cell.Z { background-color: #f00000; }

.score-panel {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.score-panel > div {
    text-align: center;
}

.score-panel span {
    font-weight: bold;
    color: #07c160;
    font-size: 18px;
}

.controls {
    display: flex;
    justify-content: center;
}

#startBtn {
    background-color: #07c160;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 6px;
    cursor: pointer;
}

#startBtn:hover {
    background-color: #059d4e;
}

/* 移动端控制按钮 */
.mobile-controls {
    display: none;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    width: 100%;
    flex-shrink: 0;
}

.mobile-row {
    display: flex;
    justify-content: center;
    margin-bottom: 10px;
    width: 100%;
}

.mobile-btn {
    background-color: #07c160;
    color: white;
    border: none;
    padding: 12px 5px;
    margin: 0 5px;
    font-size: 14px;
    border-radius: 8px;
    cursor: pointer;
    flex: 1;
    max-width: 100px;
    user-select: none; /* 防止按钮文本被选中 */
}

.mobile-btn:active {
    background-color: #059d4e;
}

.drop-btn {
    max-width: 150px !important;
}

@media (min-width: 768px) {
    /* 在桌面端隐藏移动端控制按钮 */
    .mobile-controls {
        display: none;
    }
}

/* 移动端适配 */
@media (max-width: 767px) {
    .mobile-controls {
        display: flex;
        flex-direction: column;
        margin-top: 15px;
        padding: 10px 0;
    }
    
    .game-container {
        display: flex;
        flex-direction: column;
        height: calc(100vh - 150px);
    }
    
    .game-main {
        display: flex;
        flex-direction: row;
        flex: 1;
        min-height: 0;
    }
    
    .game-board {
        flex: 2;
        display: grid;
        grid-template-columns: repeat(10, 1fr);
        grid-template-rows: repeat(20, 1fr);
        aspect-ratio: 10/20;
        max-width: 60vw;
        margin: 0 auto;
    }
    
    .cell {
        width: 100%;
        height: 100%;
    }
    
    .game-sidebar {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: flex-end;
        padding-bottom: 15px;
        max-width: 30vw;
    }
    
    .controls {
        display: none;
    }
    
    .mobile-btn {
        padding: 12px;
        margin: 5px;
        font-size: 14px;
    }
}